<?php
namespace Plugins\shanyou;
class lib
{
  public  function ksortMd5($data, $secret) {
            unset($data['sign']);
            ksort($data);
            $data['key'] = $secret;
            $str = '';
         foreach ($data as $k => $v) {
             $str .= $k . '=' . $v . '&';
         }
        $str = trim($str,'&');
        return strtolower(md5($str));
    }


    public function getSign($userId){
        $inc_type="shop_info";
        $shop_info=tpCache($inc_type);
        $shanyou_channnel_id= trim($shop_info["shanyou_channnel_id"]);
        $shanyou_secret_key=trim($shop_info["shanyou_secret_key"]);
        $signContent = $shanyou_channnel_id."-".$shanyou_secret_key.":sdkUserId=".$userId."&";
        $sign =strtoupper(md5($signContent));
        return $sign;
    }
    public function getValidateSign($taskDataRecord,$userId ,$taskId , $sdkUserId ,$taskDataMoney ,$taskDataRewardMoney ,$notifyCount){
        $inc_type="shop_info";
        $shop_info=tpCache($inc_type);
        $shanyou_channnel_id= trim($shop_info["shanyou_channnel_id"]);
        $shanyou_secret_key=trim($shop_info["shanyou_secret_key"]);
        $signContent = $shanyou_channnel_id.$shanyou_secret_key.$taskDataRecord.$userId.$taskId.$sdkUserId.$taskDataMoney.$taskDataRewardMoney.$notifyCount;
        $sign =strtoupper(md5($signContent));
        return $sign;
    }

}